<?php 

namespace app\controller\bossManager;

use share\service\UserBaseService;
use app\validate\PageValidate;
use app\validate\UserInfoValidate;
use share\service\UserDetailService;
use share\utils\Helper;

class UserInfoController extends WebBossController{

    public function initValidate(){
        $this->validate = new UserInfoValidate();
    }

    /**
     * 用户列表
     */
    public function list_action(){
        $input = $this->check();        
        $page = $this->check('pageInfo',null,(new PageValidate()));        
        $data = UserBaseService::getListInfo($input,$page);      
        $uids = array_column($data,'id');
        $userDetails = UserDetailService::getAll($uids);  
        $res = [];
        foreach($data as $item){
            $id = $item['id'];
            $detail = Helper::filterOne($userDetails,['id' => $id]);
            $tmp = array_merge($item,$detail);
            $res[] = $tmp;
        }

        $total = UserBaseService::getListCountInfo($input);
        return self::ok(self::formatPageData($page,$total,$res));
    }

    /**
     * 用户列表
     */
    public function set_nick_name_action(){
        $input = $this->check();        
        $page = $this->check('pageInfo',null,(new PageValidate()));        
        $data = UserBaseService::getListInfo($input,$page);
        return self::ok($data);
    }

   
}
